/**
 * 
 */
package com.ccqlk.attendance.common.page;

import java.util.List;

import com.google.common.collect.Lists;

/**
 * Copyright 2015-2018 重庆鲁控科技有限公司<br>
 * 文件标题: PageRequest<br>
 * 文件说明: 分页信息<br>
 * @author ZhangYinxian 348893009@qq.com<br>
 * 创建时间 2016年5月27日 上午9:26:54<br>
 */
public class PageRequest {
	private Integer pageSize = 0;
	private Integer pageNum = 0;
	private String column;
	private String directionName;
	private Sort sort;
	private List<Sort> sortList = Lists.newArrayList();
	private Direction direction;
	/**
	 * 标记是否需要计算count
	 */
	private boolean countable = true;

	public PageRequest() {
	}

	/**
	 * 分页信息
	 * @param pageNum 页码
	 * @param pageSize 每页的条数
	 */
	public PageRequest(Integer pageNum, Integer pageSize) {
		this.pageSize = pageSize;
		this.pageNum = pageNum;
	}

	/**
	 * 分页信息
	 * @param pageNum 页码
	 * @param pageSize 每页的条数
	 * @param column 排序字段
	 * @param directionName 排序方式 asc升序 desc降序
	 */
	public PageRequest(Integer pageNum, Integer pageSize, String column, String directionName) {
		this(pageNum, pageSize, new Sort(column, directionName));
	}

	/**
	 * 分页信息
	 * @param pageNum 页码
	 * @param pageSize 每页的条数
	 * @param direction 排序类型 ASC升序 DESC降序
	 * @param column 排序字段
	 */
	public PageRequest(Integer pageNum, Integer pageSize, Direction direction, String column) {
		this.pageSize = pageSize;
		this.pageNum = pageNum;
		this.column = column;
		this.direction = direction;
		this.sort = new Sort(direction, column);
	}

	/**
	 * 分页信息
	 * @param pageNum 页码
	 * @param pageSize 每页的条数
	 * @param sort 排序对象
	 */
	public PageRequest(Integer pageNum, Integer pageSize, Sort sort) {
		this.pageSize = pageSize;
		this.pageNum = pageNum;
		this.sort = sort;
		if (sort != null) {
			this.column = sort.getColumn();
			this.directionName = sort.getDirection().getName();
		}
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
	}

	public Integer getPageNum() {
		return pageNum;
	}

	public void setPageNum(Integer pageNum) {
		this.pageNum = pageNum;
	}

	public String getColumn() {
		return column;
	}

	public void setColumn(String column) {
		this.column = column;
	}

	public Sort getSort() {
		return sort;
	}

	public void setSort(Sort sort) {
		this.sort = sort;
	}

	public String getDirectionName() {
		return directionName;
	}

	public void setDirectionName(String directionName) {
		this.directionName = directionName;
	}

	public Direction getDirection() {
		return direction;
	}

	public void setDirection(Direction direction) {
		this.direction = direction;
	}

	public boolean getCountable() {
		return countable;
	}

	public void setCountable(boolean countable) {
		this.countable = countable;
	}

	public List<Sort> getSortList() {
		return sortList;
	}

	public void setSortList(List<Sort> sortList) {
		this.sortList = sortList;
	}
}
